import time
import calendar
from python_baway.common.xcommon import sep


def xshow_struct_time(xst):
    print(f'Now is year {xst.tm_year}, month {xst.tm_mon}, day {xst.tm_mday}, weekday {xst.tm_wday}, yearday {xst.tm_yday}')
    print(f'Now is {xst.tm_hour:02d}:{xst.tm_min:02d}:{xst.tm_sec:02d}')


sep('now, timestamp')
xnowts = time.time()
print(time.ctime(xnowts))

sep('now, struct_time, time.localtime')
xnowst = time.localtime(xnowts)
print(time.asctime(xnowst))
xshow_struct_time(xnowst)
xnowts2 = time.mktime(xnowst)
print(time.ctime(xnowts2))

sep('now, struct_time, time.gmtime')
xnowst_gm = time.gmtime(xnowts)
print(time.asctime(xnowst_gm))

sep('mktime(xnowst_gm)')
xnowts3 = time.mktime(xnowst_gm)
print(time.ctime(xnowts3))

sep('calendar.timegm(xnowst_gm)')
xnowts4 = calendar.timegm(xnowst_gm)
print(time.ctime(xnowts4))
